home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 04 - 1988 / 04.10 Oct 88 / MSSourcesLong / MST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-01-20  |  16.2 KB  |  772 lines  |  [TEXT/EDIT]

  1.  
  2. /*________________________________
  3.                     MSTst.c
  4.   ________________________________
  5. OPTIONS B=token E=verb G=ASM H=ASM Src J=ASM Symb K=Debug Symb Z=No float
  6.   ________________________________*/
  7. #Options +B +E -G -H +J +K +Z
  8. #asm
  9. .verbose
  10. #endasm
  11. #include    "MyTools.p"
  12. #include    "MS.h"
  13. #include    "MST.h"
  14.  
  15. /* Non-int functions */
  16. extern    MSHdl        MSGetMSH();
  17.  
  18. /* function addresses passed to MSTIndxRes */
  19.  
  20. pascal int PopUpMenuSelect(theMH,Top,Left,PopItem)
  21.     MenuHandle    theMH;
  22.     short        Top,Left,PopItem;
  23.     extern 0xA80B;
  24.  
  25. extern    reStartProc();
  26. extern    MSTAdjTog();
  27. extern    MSTAdjPREV();
  28. extern    MSTInitMenu();
  29. extern    MSTMIVTDump();
  30. extern    MSTDump();
  31.  
  32.  
  33. /* GLOBALS */
  34. TEHandle    theTEH;            /* for Dumps transferred to Desk Scrap */
  35. MSConfig    MSTConfg;
  36.  
  37. main()
  38. BEGIN_PROG
  39. //#asm
  40. //    DC.W $FF01
  41. //#endasm
  42.     EventRecord        theEvent;
  43.     char            c;
  44.     WindowPtr        theWindow;
  45.     short            windowCode;
  46.     long            menuResult;
  47.     int                i,j;
  48.     Rect            vRect,dRect;
  49.     Point            **mTabH;
  50.     short            progNum=_MSTPRG08;
  51.  
  52. MoreMasters();
  53. MoreMasters();
  54. MoreMasters();
  55. MoreMasters();
  56.  
  57. InitMenus();
  58. InitCursor();
  59. InitDialogs(&reStartProc);
  60. TEInit();
  61. MSTConfg=MSInit(0);
  62. SetRect(&vRect,10000,10000,10200,10200);
  63. SetRect(&dRect,10000,10000,10200,10200);
  64. theTEH=TENew(&dRect,&vRect);
  65. MSTNonMS(1);
  66. DrawMenuBar();
  67.  
  68. if (NOT(mTabH=(Point **)GetResource(_MSCFGTYP,1)))
  69.     MSErrExit(progNum,-_MSTERR01,NULL,NULL);
  70. menuResult=*(long *)((*mTabH)+_MSTMMEN);
  71. MSTDoMenu(menuResult);
  72.  
  73. FlushEvents(everyEvent);
  74. WHILE (TRUE)
  75.     IF (GetNextEvent(everyEvent,&theEvent))
  76.     THEN
  77.         SWIT (theEvent.what)
  78.             CASE (keyDown)
  79.                 c=theEvent.message BAND charCodeMask;
  80.                 if (theEvent.modifiers BAND cmdKey)
  81.                     MSTDoMenu(MenuKey(c));
  82.             ENDCASE
  83.             CASE (mouseDown)
  84.                 windowCode=FindWindow(&theEvent.where,&theWindow);
  85.                 SWIT (windowCode)
  86.                     CASE (inMenuBar)
  87.                         menuResult=MenuSelect(&theEvent.where);
  88.                         MSTDoMenu(menuResult);
  89.                     ENDCASE
  90.                     CASE (inSysWindow)
  91.                         SystemClick(&theEvent,theWindow);
  92.                     ENDCASE
  93.                 ENDSWIT
  94.             ENDCASE
  95.         ENDSWIT
  96.     ENDIF
  97.     SystemTask();
  98. ENDWHILE
  99.  
  100. END_PROG
  101. //================
  102. reStartProc(){ExitToShell()}
  103. //================
  104. //=================
  105. MSTDoMenu(menuResult)
  106. long    menuResult;
  107. //=================
  108. BEGIN_FCT
  109.     short        menuID, itemNumber;
  110.     WindowPtr    currWindow;
  111.     MenuHandle    theMH;
  112.     Str255        paramStr[4],theStr1,theStr2;
  113.     int            itemFlg,i;
  114.     Point        **mTabH,*mTabP,mTab;
  115.     short        upper,lower,strID, strIndx,actFlg,retVal;
  116.     short        progNum=-_MSTPRG01;
  117.     long        theID,theItem,theCkBx;
  118.     short        MSerr;
  119.     MenuVerb    theMV;
  120.     Handle        theHdl;
  121.     int            (*actFct)();
  122.  
  123.  
  124. menuID=HiWord(menuResult);
  125. itemNumber=LoWord(menuResult);
  126. MSDispatch(menuID,itemNumber);
  127.  
  128. if (NOT(mTabH=(Point **)GetResource(_MSCFGTYP,1)))
  129.     MSErrExit(progNum,-_MSTERR01,NULL,NULL);
  130. HLock(mTabH);
  131. mTabP=*mTabH;
  132.  
  133. FOR (itemFlg=NULL;itemFlg LT _MSTVRBL;itemFlg++)
  134.     mTab=*(mTabP+itemFlg);
  135.     IF (menuID EQ mTab.v)
  136.     THEN
  137.         if (itemFlg EQ _MSTDESK)
  138.             break;
  139.         if (itemFlg EQ _MSTEDIT)
  140.             break;
  141.         if (itemNumber EQ mTab.h)
  142.             break;
  143.     ENDIF
  144. ENDFOR
  145. for (i=NULL;i LT 4;i++)
  146.     paramStr[i].count=NULL;
  147.  
  148. IF (itemFlg LT _MSTVRBL)
  149. THEN
  150.     SWIT (itemFlg)
  151.         CASE (_MSTDESK)
  152.             if (itemNumber GE (mTabP+_MSTDESK)->h)
  153.                 MSTOpenDA(menuID,itemNumber);
  154.         ENDCASE
  155.         CASE (_MSTEDIT)
  156.             if (itemNumber LE (mTabP+_MSTEDIT)->h)
  157.                 SystemEdit(itemNumber-1);
  158.         ENDCASE
  159.         CASE (_MSTQUIT)
  160.             MSTCloseDAs();
  161.             ExitToShell();
  162.         ENDCASE
  163.         CASE (_MSTTRNF)
  164.             MSTCloseDAs();
  165.             DoTransfer();
  166.         ENDCASE
  167.         CASE (_MSTNNMS)
  168.             MSTNonMS(0);
  169.             DrawMenuBar();
  170.         ENDCASE
  171.         CASE (_MSTINSM)
  172.             fGetIndStr(¶mStr[0],MSTConfg.prgStrID ,_MSPRG12);
  173.             fGetIndStr(¶mStr[1],MSTConfg.altErrStrID ,_MSTERR03);
  174.             fGetIndStr(¶mStr[2],MSTConfg.altErrStrID ,_MSTERR07);
  175.             fGetIndStr(¶mStr[3],MSTConfg.altErrStrID ,_MSTERR04);
  176.             ParamText(¶mStr[0],¶mStr[1],¶mStr[2],¶mStr[3]);
  177.             WHILE (TRUE)
  178.                 MSerr=FALSE;
  179.                 IF (MSTDialog(&theID,&theStr1,&theItem,&theStr2,0))
  180.                 THEN
  181.                     for (i=NULL; i LT sizeof(MenuVerb);i++)
  182.                         *((char *)(&theMV)+i)=NULL;
  183.  
  184.  
  185.                     if (theStr2.count MOD 2 
  186.                         OR theStr2.count GT sizeof(MenuVerb)*2)
  187.                         MSerr=TRUE;
  188.                     else
  189.                         for (i=NULL; i LT theStr2.count;i+=2)
  190.                             if ((upper=MSTHexVal(theStr2.s[i])) LT NULL
  191.                                 OR (lower=MSTHexVal(theStr2.s[i+1])) LT NULL)
  192.                                 MSerr=TRUE;
  193.                             else
  194.                                 *((char *)(&theMV)+i/2)=upper*16+lower;
  195.  
  196.                     if (MSerr)
  197.                     {    SysBeep(20);continue;}
  198.                     MSerr=MSInsMenuItem(theID,&theStr1,theItem,&theMV);
  199.                     if (MSerr LT NULL)
  200.                         MSErrExit(_MSPRG12,-MSerr,theID,theItem);
  201.                 ENDIF
  202.                 break;
  203.             ENDWHILE
  204.         ENDCASE
  205.         CASE (_MSTDELM)
  206.         CASE (_MSTTGBT)
  207.         CASE (_MSTPOPM)
  208.             theID=1;theStr1.count=0;theItem=1;theStr2.count=0;
  209.             fGetIndStr(¶mStr[2],MSTConfg.altErrStrID ,_MSTERR08);
  210.  
  211.             SWIT (itemFlg)
  212.                 CASE (_MSTDELM)
  213.                     fGetIndStr(¶mStr[0],MSTConfg.prgStrID ,_MSPRG13);
  214.                 ENDCASE
  215.                 CASE (_MSTTGBT)
  216.                     fGetIndStr(¶mStr[0],MSTConfg.prgStrID ,_MSPRG09);
  217.                 ENDCASE
  218.                 CASE (_MSTPOPM)
  219.                     fGetIndStr(¶mStr[0],MSTConfg.altErrStrID ,_MSTERR09);
  220.                     theItem=0;
  221.                 ENDCASE
  222.             ENDSWIT
  223.  
  224.             ParamText(¶mStr[0],¶mStr[1],¶mStr[2],¶mStr[3]);
  225.             IF (MSTDialog(    theID?&theID:0,    theStr1.count?&theStr1:0,
  226.                             theItem?&theItem:0,    theStr2.count?&theStr2:0,    0))
  227.             THEN
  228.                 SWIT (itemFlg)
  229.                     CASE (_MSTDELM)
  230.                         MSerr=MSDelMenuItem(theID,theItem);
  231.                         if (MSerr LT NULL)
  232.                             MSErrExit(_MSPRG13,-MSerr,theID,theItem);
  233.                     ENDCASE
  234.                     CASE (_MSTTGBT)
  235.                         MSTogBit(theID,theItem);
  236.                     ENDCASE
  237.                     CASE (_MSTPOPM)
  238.                         fGetIndStr(¶mStr[0],MSTConfg.altErrStrID ,_MSTERR05);
  239.                         ParamText(¶mStr[0],¶mStr[1],¶mStr[2],¶mStr[3]);
  240.                         MSTPopUp(theID);
  241.                     ENDCASE
  242.                 ENDSWIT
  243.             ENDIF
  244.         ENDCASE
  245.         CASE (_MSTDMEN)
  246.         CASE (_MSTMMEN)
  247.         CASE (_MSTADJT)
  248.         CASE (_MSTADJP)
  249.         CASE (_MSTMIVT)
  250.         CASE (_MSTDUMP)
  251.             strID=MSTConfg.altErrStrID;
  252.             theItem=_MSMSTTYP;
  253.             actFct=NIL;
  254.             actFlg=NULL;
  255.             SWIT (itemFlg)
  256.                 CASE (_MSTDMEN)
  257.                 CASE (_MSTMMEN)
  258.                     strIndx=(itemFlg EQ _MSTDMEN)?_MSTERR11:_MSTERR12;
  259.                     actFlg=(itemFlg EQ _MSTDMEN)?FALSE:TRUE;
  260.                     actFct=MSTInitMenu;
  261.                 ENDCASE
  262.                 CASE (_MSTADJT)
  263.                 CASE (_MSTADJP)
  264.                     theItem=_MSPRVTYP;
  265.                     strID=MSTConfg.prgStrID;
  266.                     strIndx=(itemFlg EQ _MSTADJT)?_MSPRG08:_MSPRG10;
  267.                     actFct=(itemFlg EQ _MSTADJT)?MSTAdjTog:MSTAdjPREV;
  268.                 ENDCASE
  269.                 CASE (_MSTDUMP)
  270.                 CASE (_MSTMIVT)
  271.                     strID=MSTConfg.altPrgStrID;
  272.                     strIndx=(itemFlg EQ _MSTDUMP)?_MSTPRG06:_MSTPRG07;
  273.                     actFct=(itemFlg EQ _MSTDUMP)?MSTDump:MSTMIVTDump;
  274.                 ENDCASE
  275.             ENDSWIT
  276.  
  277.             fGetIndStr(¶mStr[0],strID ,strIndx);
  278.             ParamText(¶mStr[0],¶mStr[1],¶mStr[2],¶mStr[3]);
  279.             IF (MSTDialog(&theID,0,0,0,&theCkBx))
  280.             THEN
  281.                 IF (theCkBx)
  282.                 THEN
  283.                     MSTIndxRes(theItem,actFct,actFlg);
  284.                 ELSE
  285.                     (*actFct)(theID,actFlg);
  286.                 ENDIF
  287.                 DrawMenuBar();
  288.                 SWIT (itemFlg)
  289.                     CASE (_MSTDUMP)
  290.                     CASE (_MSTMIVT)
  291.                         TESetSelect(0,32767,theTEH);
  292.                         TECut(theTEH);
  293.                         /* copy TE scrap to desk scrap for DA's */
  294.                         if ((i=TEToScrap()) LT NULL) 
  295.                             MSErrExit(progNum,-_MSTERR06,NULL,i);
  296.                     ENDCASE
  297.                 ENDSWIT
  298.             ENDIF
  299.         ENDCASE
  300.     ENDSWIT
  301. ENDIF
  302.  
  303. HUnlock(mTabH);
  304. ReleaseResource(mTabH);
  305. HiliteMenu(0);
  306.  
  307. END_FCT
  308. //==========
  309. MSTHexVal(c)
  310.     char c;
  311. //==========
  312. BEGIN_FCT
  313.     IF (isdigit(c))
  314.     THEN    return (c-'30');
  315.     ELSE    c=toupper(c);
  316.             c-='A';
  317.             IF (c GE NULL AND c LE 5)
  318.             THEN    return (c+10);
  319.             ELSE    return (-1)
  320.             ENDIF
  321.     ENDIF
  322.         
  323. END_FCT
  324.  
  325. //=====================================
  326. MSTOpenDA(menuID,itemNumber)
  327.     short    menuID,itemNumber;
  328. //=====================================
  329. BEGIN_FCT
  330.     Str255            theStr;
  331.     WindowPtr        currWindow;
  332.     MenuHandle        theMH;
  333.     short            progNum=-_MSTPRG02;
  334.  
  335.     GetPort(&currWindow);
  336.     theMH=(*MSGetMSH(menuID,progNum))->MH;
  337.     GetItem(theMH,itemNumber,&theStr);
  338.     OpenDeskAcc(&theStr);
  339.     SetPort(currWindow);
  340.  
  341. END_FCT
  342. //=========
  343. MSTCloseDAs()
  344. //=========
  345. BEGIN_FCT
  346.     short        refNum;
  347.  
  348.     while ((refNum=_WINDKIND(FrontWindow())) LE NULL)
  349.         CloseDeskAcc(refNum);
  350.  
  351. END_FCT
  352. //================
  353. MSTMIVTfct(menuID,MIVTfct1,MIVTfct2)
  354. short    menuID;
  355. long    *MIVTfct1,*MIVTfct2;
  356. //=================
  357. /* This Function should be tailored 
  358.     to load addresses of non-PROC MIVT fcts for testing purposes*/
  359. BEGIN_FCT
  360.     #define    _MSTIDTDIM    1
  361.     struct
  362.     {    short    tabID;
  363.         int        tabAdd1;
  364.         int        tabAdd2;
  365.     }IDTab[_MSTIDTDIM];
  366.     int        i;
  367.  
  368.     /* Init Tab to ID, MIVTfct @ 
  369.         - don't forget global extern declaration */
  370.     IDTab[NULL].tabID=-1;
  371.     IDTab[NULL].tabAdd1=NIL;
  372.     IDTab[NULL].tabAdd2=NIL;
  373.     /**/
  374.     *MIVTfct1 =NULL;
  375.     *MIVTfct2 =NULL;
  376.     for (i=NULL; i LT _MSTIDTDIM;i++)
  377.         IF (IDTab[i].tabID EQ menuID)
  378.         THEN
  379.             *MIVTfct1 =IDTab[i].tabAdd1;
  380.             *MIVTfct2 =IDTab[i].tabAdd2;
  381.             break;
  382.         ENDIF
  383.     return;
  384.     
  385. END_FCT
  386. //==============
  387. MSTNonMS(flg)
  388.     short    flg;
  389. //==============
  390. BEGIN_FCT
  391.     Point        **mTabH,*mTabP,mTab;
  392.     MenuHandle    theMH;
  393.     short        i,count;
  394.     char        before;
  395.     short        progNum=-_MSTPRG04;
  396.  
  397. if (NOT(mTabH=(Point **)GetResource(_MSCFGTYP,1)))
  398.     return;
  399. HLock(mTabH);
  400. mTabP=*mTabH;
  401. count=GetHandleSize((Handle)mTabH);
  402. count/=sizeof(Point);
  403. FOR (i=_MSTVRBL; i LT count;i++)
  404.     mTab=*(mTabP+i);
  405.     before=mTab.h BAND 0xFF00?TRUE:FALSE;
  406.     IF (    (before AND flg) OR NOT (before OR flg)    )
  407.     THEN
  408.         if (NOT (theMH=GetMenu(mTab.v)) )
  409.             MSErrExit(progNum,_MSERR02,mTab.v,0);
  410.         before=mTab.h BAND 0x00FF;
  411.         InsertMenu(theMH,before);
  412.     ENDIF
  413. ENDFOR
  414. HUnlock(mTabH);
  415.  
  416. END_FCT
  417. //==================
  418. MSTDialog(menuID,menuStr,after,theMV,theCkBx)
  419.     long        *menuID;
  420.     Str255        *menuStr;
  421.     long        *after;
  422.     Str255        *theMV;
  423.     long        *theCkBx;
  424. //==================
  425. BEGIN_FCT
  426.  
  427. DialogPtr        theDP;
  428. WindowPtr        currWindow;
  429. Str255            pStr0;
  430. ControlHandle    theCH;
  431. Rect            theRect;
  432. short            itemNum,itemType;
  433. int                retVal;
  434.  
  435.  
  436. GetPort(&currWindow);
  437. theDP=GetNewDialog(_MSTDLGDID,NIL,(DialogPtr)-1);
  438. SetPort(theDP);
  439. MSTDialog1(theDP,menuID,menuStr,after,theMV,theCkBx);
  440. itemNum=-1;
  441. WHILE (itemNum NE oK    AND    itemNum NE cancel)
  442.     ModalDialog(NIL,&itemNum);
  443.     IF (itemNum EQ _MSTDLGCBX)
  444.     THEN
  445.         GetDItem(theDP,_MSTDLGCBX,&itemType,&theCH,&theRect);
  446.         SetCtlValue(theCH,NOT GetCtlValue(theCH));
  447.     ENDIF
  448. ENDWHILE
  449. retVal=FALSE;
  450. IF (itemNum EQ oK)
  451. THEN
  452.         retVal=TRUE;
  453.         IF (menuID NE NIL)
  454.         THEN
  455.             GetDItem(theDP,_MSTDLGMID,&itemType,&theCH,&theRect);
  456.             GetIText(theCH,&pStr0);
  457.             StringToNum(&pStr0,menuID);
  458.         ENDIF
  459.         IF (menuStr NE NIL)
  460.         THEN
  461.             GetDItem(theDP,_MSTDLGSTR,&itemType,&theCH,&theRect);
  462.             GetIText(theCH,menuStr);
  463.         ENDIF
  464.         IF (after NE NIL)
  465.         THEN
  466.             GetDItem(theDP,_MSTDLGAFT,&itemType,&theCH,&theRect);
  467.             GetIText(theCH,&pStr0);
  468.             StringToNum(&pStr0,after);
  469.         ENDIF
  470.         IF (theMV NE NIL)
  471.         THEN
  472.             GetDItem(theDP,_MSTDLGOPC,&itemType,&theCH,&theRect);
  473.             GetIText(theCH,theMV);
  474.         ENDIF
  475.         IF (theCkBx NE NIL)
  476.         THEN
  477.             GetDItem(theDP,_MSTDLGCBX,&itemType,&theCH,&theRect);
  478.             *theCkBx=GetCtlValue(theCH);
  479.         ENDIF
  480. ENDIF
  481.  
  482. DisposDialog(theDP);
  483. SetPort(currWindow);
  484. return(retVal);
  485. END_FCT
  486. //==================
  487. MSTDialog1(theDP,menuID,menuStr,after,theMV,theCkBx)
  488.     DialogPtr    theDP;
  489.     long        *menuID;
  490.     Str255        *menuStr;
  491.     long        *after;
  492.     Str255        *theMV;
  493.     long        *theCkBx;
  494. //==================
  495. BEGIN_FCT
  496.  
  497. ControlHandle    theCH;
  498. Rect            theRect;
  499. PenState        currPen;
  500. short            theShort;
  501.  
  502.  
  503. GetDItem(theDP,oK,&theShort,&theCH,&theRect);
  504. GetPenState(&currPen);
  505. PenSize(2,2);
  506. InsetRect(&theRect,-3,-3);
  507. FrameRoundRect(&theRect,16,16);
  508. SetPenState(&currPen);
  509.  
  510. SelIText(theDP,_MSTDLGMID,0,32767);
  511.  
  512. if (menuID EQ NIL)
  513.     HideDItem(theDP,_MSTDLGMID);
  514. if (menuStr EQ NIL)
  515.     HideDItem(theDP,_MSTDLGSTR);
  516. if (after EQ NIL)
  517.     HideDItem(theDP,_MSTDLGAFT);
  518. if (theMV EQ NIL)
  519.     HideDItem(theDP,_MSTDLGOPC);
  520. if (theCkBx EQ NIL)
  521.     HideDItem(theDP,_MSTDLGCBX);
  522.  
  523.  
  524. END_FCT
  525. //==============
  526. MSTPopUp(menuID)
  527. long    menuID;
  528. //==============
  529. BEGIN_FCT
  530. DialogPtr        theDP;
  531. WindowPtr        currWindow;
  532. Str255            pStr0;
  533. ControlHandle    theCH;
  534. Rect            theRect;
  535. short            theShort;
  536. int                flg;
  537. long            menuResult;
  538. MenuHandle        theMH;
  539. MSHdl            theMSH;
  540. short            progNum=-_MSTPRG05;
  541.  
  542.  
  543. GetPort(&currWindow);
  544. theDP=GetNewDialog(_MSTDLGDID,NIL,(DialogPtr)-1);
  545. SetPort(theDP);
  546. HideDItem(theDP,_MSTDLGMID);
  547. HideDItem(theDP,_MSTDLGIDT);
  548. MSTDialog1(theDP,0,0,0,0);
  549. GetDItem(theDP,_MSTDLGICN,&theShort,&theCH,&theRect);
  550. LocalToGlobal(&theRect.topLeft);
  551. LocalToGlobal(&theRect.botRight);
  552. theMSH=MSGetMSH(menuID,progNum);
  553. theMH=(*theMSH)->MH;
  554. flg=FALSE;
  555. IF (NOT BitTst((*theMSH)->MVT, _MFSUBMEN))
  556. THEN
  557.     flg=TRUE;
  558.     DeleteMenu(menuID);
  559.     MSInsert(menuID,-1);
  560. ENDIF
  561.  
  562.  
  563. WHILE (TRUE)
  564.     ModalDialog(NIL,&theShort);
  565.     if (theShort NE _MSTDLGICN)
  566.         break;
  567.  
  568.     menuResult=PopUpMenuSelect(theMH,theRect.top,theRect.left,1);
  569.     MSTDoMenu(menuResult);
  570.  
  571. ENDWHILE
  572.  
  573. IF (flg)
  574. THEN
  575.     DeleteMenu(menuID);
  576.     MSInsert(menuID,(*theMSH)->beforeID);
  577.     DrawMenuBar();
  578. ENDIF
  579.  
  580. DisposDialog(theDP);
  581. SetPort(currWindow);
  582. return;
  583.  
  584. END_FCT
  585. //===========
  586. MSTIndxRes(typ,fct,flg)
  587. long    typ;
  588. int        (*fct)();
  589. int        flg;
  590. //===========
  591. BEGIN_FCT
  592.     short    theCount;
  593.     int        i;
  594.     Handle    theHandle;
  595.     Str255    theStr;
  596.     short    theID;
  597.  
  598. theCount=CountResources(typ);
  599. FOR (i=1;i LE theCount;i++)
  600.     theHandle=GetIndResource(typ,i);
  601.     GetResInfo(theHandle,&theID,&typ,&theStr);
  602.     (*fct)(theID,flg);
  603. ENDFOR
  604.  
  605. END_FCT
  606. //=======================
  607. MSTDump(theID,flg)
  608. short    theID;
  609. int        flg;
  610. //=======================
  611. BEGIN_FCT
  612. /* Short by short,sprintf() MSH to TE, put in Scrap */
  613.  
  614. MSHdl        theMSH;
  615. Str255        pStr1,pStr2;
  616. int            i,j,k,HdlSze;
  617. short        progNum=-_MSTPRG06;
  618.  
  619.  
  620. IF (NOT (theMSH=(MSHdl)GetResource(_MSMSTTYP,theID)))
  621. THEN    MSErrExit(progNum,_MSERR01,theID,NULL);
  622. ELSE
  623.     pStr1.count=pStr2.count=NULL;
  624.     fGetIndStr(&pStr1,MSTConfg.altErrStrID ,_MSTERR10);
  625.     PtoCstr(&pStr1);
  626.     sprintf(&pStr2," %s%d\n\n",&pStr1,theID);
  627.     TEInsert(&pStr2,strlen(&pStr2),theTEH);
  628.     HdlSze=GetHandleSize(theMSH);
  629.     HdlSze/=sizeof(short);
  630.     FOR (i=NULL;i LT HdlSze;i++)
  631.         sprintf(&pStr2,"%04X ",*((unsigned short *)(*theMSH)+i));
  632.         TEInsert(&pStr2,strlen(&pStr2),theTEH);
  633.     ENDFOR
  634.     sprintf(&pStr2,"\n\n");
  635.     TEInsert(&pStr2,strlen(&pStr2),theTEH);        
  636. ENDIF
  637.     
  638.  
  639. END_FCT
  640.  
  641. /* These Functions called by MSTIndxRes with (ResID,flg) */
  642.  
  643. //===================
  644. MSTMIVTDump(theID,flg)
  645. short    theID;
  646. int        flg;
  647. //=======================
  648. BEGIN_FCT
  649. /* Loop on MSGetMIVT, sprintf() to TE, put in Scrap */
  650.  
  651. MSHdl        theMSH;
  652. Str255        pStr1,pStr2;
  653. long        MIVTi;
  654. int            i,j,k,maxMIVT;
  655.  
  656.  
  657. theMSH=(MSHdl)GetResource(_MSMSTTYP,theID);
  658. /* this test might be changed to _MFBLDTAB */
  659.  
  660. IF (BitTst((*theMSH)->MVT, _MFALOCTB))
  661. THEN
  662.     pStr1.count=pStr2.count=NULL;
  663.     fGetIndStr(&pStr1,MSTConfg.altErrStrID ,_MSTERR02);
  664.     PtoCstr(&pStr1);
  665.     sprintf(&pStr2," %s%d\n\n",&pStr1,theID);
  666.     TEInsert(&pStr2,strlen(&pStr2),theTEH);
  667.     maxMIVT=(*theMSH)->allocCount;
  668.     FOR (i=NULL;i LE maxMIVT;i++)
  669.         MIVTi=MSGetMIVT(theID,i);
  670.         FOR (j=NULL;j LT (sizeof(long)/sizeof(short));j++)
  671.             sprintf(&pStr2,"%04X ",*((unsigned short *)(&MIVTi)+j));
  672.             TEInsert(&pStr2,strlen(&pStr2),theTEH);
  673.         ENDFOR
  674.     ENDFOR
  675.     sprintf(&pStr2,"\n\n");
  676.     TEInsert(&pStr2,strlen(&pStr2),theTEH);
  677. ENDIF
  678.  
  679. END_FCT
  680. //=====================
  681. MSTInitMenu(theID,flg)
  682. short    theID;
  683. int        flg;
  684. //=======================
  685. BEGIN_FCT
  686. int        MIVTfct1,MIVTfct2;
  687. IF (flg AND NOT GetMHandle(theID))
  688. THEN    MSTMIVTfct(theID,&MIVTfct1,&MIVTfct2);
  689.         MSMake(theID, MIVTfct1,MIVTfct2);
  690.         MSInsert(theID, 0);
  691. ENDIF
  692. IF (NOT flg AND  GetMHandle(theID))
  693. THEN    DeleteMenu(theID);
  694.         MSDispose(theID);
  695. ENDIF
  696.  
  697. END_FCT
  698. //====================
  699. MSTAdjPREV(theID,flg)
  700. short    theID;
  701. int        flg;
  702. //====================
  703. BEGIN_FCT
  704. MSAdjPREV(theID);
  705. END_FCT
  706. //====================
  707. MSTAdjTog(theID,flg)
  708. short    theID;
  709. int        flg;
  710. //====================
  711. BEGIN_FCT
  712. Handle    theHandle;
  713. short    progNum=-_MSTPRG04;
  714.  
  715. if (NOT (theHandle=GetResource(_MSPRVTYP,theID)) )
  716.     MSErrExit(progNum,_MSERR12,theID,0);
  717. HLock(theHandle);
  718. MSAdjTog(theID,*theHandle,*theHandle+sizeof(ToggleFlag));
  719. HUnlock(theHandle);
  720. ReleaseResource(theHandle);
  721.  
  722. END_FCT
  723. //=================
  724. void   DoTransfer()
  725. //=================
  726. BEGIN_FCT
  727.    SFTypeList    typeList;
  728.    short          numTypes;
  729.    IOParam       volInfo;
  730.    SFReply       reply;
  731.    Point         loc;
  732.    OSErr         theErr;
  733.  
  734.    /* select filetypes for SFGet */
  735.    numTypes = 1;
  736.    typeList.ftype[0] = 'APPL';
  737.  
  738.    /* select the file to transfer to: use custom dialog with Transfer Button */
  739.    SetPt(&loc,100,80);
  740.    SFGetFile(&loc, NIL, (Ptr) NIL, numTypes, &typeList, NIL, &reply, NIL, (Ptr) NIL);
  741.  
  742.    /* to Finder if user cancels */
  743.    if(reply.good != TRUE) return;
  744.  
  745.    /* set default volume to the one selected by user */
  746.    volInfo.ioVRefNum = reply.vRefNum;
  747.    volInfo.ioNamePtr = NIL;
  748.    theErr = PBSetVol(&volInfo, FALSE);
  749.    if(theErr)    ExitToShell();
  750.   
  751.    /* Transfer */
  752.    CLaunch(&reply.fName, NIL);
  753.  
  754. END_FCT
  755. //=========
  756. TEToScrap()
  757. //=========
  758. BEGIN_FCT
  759.    Ptr   *TEScrapH;
  760.    long  length;  
  761.    
  762.    HLock(TEScrapH = _TESCRPHDL);
  763.    
  764.    ZeroScrap();
  765.    length = PutScrap(_TESCRPLEN, 'TEXT', *TEScrapH);
  766.    
  767.    HUnlock(TEScrapH);
  768.     
  769.    return (length);
  770.  
  771. END_FCT
  772.